#include <func.h>

void cleanup(void*p)
{
    printf("i am %ld\n",(long)p);
}

void*function(void*p)
{
    pthread_cleanup_push(cleanup,(void*)1);
    pthread_cleanup_push(cleanup,(void*)2);
    sleep(1);
    pthread_cleanup_pop(1);
    pthread_cleanup_pop(1);
    return NULL;
}

int main()
{
    pthread_t pth;
    int ret=pthread_create(&pth,NULL,function,NULL);
    THREAD_ERR_CHECK(ret,"pthread_create");
    ret=pthread_cancel(pth);
    THREAD_ERR_CHECK(ret,"pthread_cancel");
    ret=pthread_join(pth,NULL);
    THREAD_ERR_CHECK(ret,"pthread_join");
    printf("hello\n");
    return 0;
}